package com.kyrioscraft.cloud.common.util;

import com.kyrioscraft.cloud.common.vo.RestResponse;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;

public class ParamValidator {

    public static RestResponse checkParam(BindingResult bindingResult) {
        if(bindingResult.hasErrors()){
            for (ObjectError error: bindingResult.getAllErrors()) {
                return RestResponse.fail(error.getDefaultMessage());
            }
        }
        return RestResponse.success();
    }
}
